﻿
using System;

namespace Assets.Scripts.UI
{
    public enum Key
    {
        Space,

        A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z,

        Digit0,
        Digit1,
        Digit2,
        Digit3,
        Digit4,
        Digit5,
        Digit6,
        Digit7,
        Digit8,
        Digit9,

        Accent,
        Dash,
        Equals,
        OpenBracket,
        CloseBracket,
        Backslash,
        Semicolon,
        Apostrophe,
        Comma,
        Period,
        Slash,

        Enter,
        Tab,
        Backspace,
        Delete,
        Escape,

        Up,
        Down,
        Left,
        Right,

        F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24
    }

    public struct KeyInfo : IEquatable<KeyInfo>
    {
        public Key Key;
        public bool Shift;
        public bool Control;
        public bool Down;
        public KeyInfo(Key key, bool shift)
        {
            Key = key;
            Shift = shift;
            Control = false;
            Down = true;
        }

        public KeyInfo(Key key)
            : this(key, false)
        {
        }

        public bool Equals(KeyInfo other)
        {
            if (Key != other.Key) return false;
            if (Shift != other.Shift) return false;
            if (Control != other.Control) return false;

            return true;
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            return obj is KeyInfo && Equals((KeyInfo) obj);
        }

        public override int GetHashCode()
        {
            return Key.GetHashCode() + Shift.GetHashCode() + Control.GetHashCode();
        }
    }
}
